﻿<!DOCTYPE html>
<html>
<head>
    <title>游戏特权</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="Resource/ui-progress-bar.css" rel="stylesheet" type="text/css" />
    <link href="Resource/buttons.css" rel="stylesheet" type="text/css" />
    <link href="Resource/site.css" rel="stylesheet" type="text/css" />
    <script src="Resource/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="Resource/iscroll.js" type="text/javascript"></script>
    <script type="text/javascript">
        var history = new Array();
        var baseurl = "http://www.itequan.com/";
        var myScroll;
        var uuid = getParameter("uuid");
        var dtype = getParameter("dtype");
        var url = getParameter("url");
        if (uuid == "") {
            uuid = "0000000000000000-000000000000000";
        }
        if (dtype == "") {
            dtype = "测试";
        }
        function getParameter(param) {
            var query = window.location.search;
            var iLen = param.length;
            var iStart = query.indexOf(param);
            if (iStart == -1)
                return "";
            iStart += iLen + 1;
            var iEnd = query.indexOf("&", iStart);
            if (iEnd == -1)
                return query.substring(iStart);
            return query.substring(iStart, iEnd);
        }
        var isLoading = false;
        function loadPage(page, isFill) {
            if (isLoading == true) {
                return false;
            }

            if (isFill == true) {
                if (page.indexOf("?") == -1) {
                    page = page + "?uuid=" + uuid + "&dtype=" + dtype;
                }
                else {
                    page = page + "&uuid=" + uuid + "&dtype=" + dtype;
                }
            }
            var menu = "";
            if (page.search("PhoneApp/Index")>=0) {
                menu = "index";
            }
            else if (page.search("PhoneApp/NewArea") >= 0) {
                menu = "newarea";
            }
            else if (page.search("PhoneApp/GameClassify") >= 0) {
                menu = "gameclassify";
            }
            else if (page.search("PhoneApp/MyCode") >= 0) {
                menu = "mycode";
            }
            if (menu != "") {
                $("li.menu").removeClass("navbar_active");
                $("li." + menu).addClass("navbar_active");
            }
            page = page.replace(/[&]/g, '*');

            page = baseurl + "PhoneApp/Jsonp?url="+page;
            
            isLoading = true;
            $('#loading_contain').show();
            $('#error_contain').hide();
                $.ajax({
                type: "get", 
                timeout:10000,
                url: page,         //请求链接 
                dataType: "jsonp",
                success: function(data) {
                    if(data.Success == true)
                    {
                            isLoading = false;
                            $('#loading_contain').hide();
//                            $('#error_contain').hide();
                            $("#scroller").html(data.Html);
                            
                            if(typeof(eval("pageStart")) == "function")
                            {
                                pageStart();
                            }
                    }
                    else
                    {
                        isLoading = false;
                        $('#rotate_contain').hide();
                        $('.loading_text').text('网络不通，请重新尝试');
                    }
                },
                error: function () {
                    isLoading = false;
                    $('#rotate_contain').hide();
                    $('.loading_text').text('网络不通，请重新尝试');
                }
            });
        }

        function setNews() {
            var url = baseurl + "PhoneApp/GetNews";
            $.ajax({
                type: "get",  //提交方式 
                url: url,         //请求链接 
                dataType: "jsonp",
                success: function (result) {
                    if (result != "") {
                        $(".title_contain").html(result);
                    }
                }
            });
        }

        function setSearch() {
            var url = baseurl + "PhoneApp/GetSearchValue";
            $.ajax({
                type: "get",  //提交方式 
                url: url,         //请求链接 
                dataType: "jsonp",
                success: function (result) {
                    if (result.search != "") {
                        $(".searchtxt").attr("value", result.search);
                    }
                }
            });
        }
        function setContent() {

            if (url == "") {
                loadPage("PhoneApp/Index", true);
            }
            else
            {
                url = url.replace(/[~]/g, '=');
                url = url.replace(/[!]/g, '?');
                url = url.replace(/[*]/g, '&');
                url = url.replace(/[|]/g, '/');

                loadPage(url, true);
            }
        }
        $(document).ready(function () {
            initHeader();

            $('#error_contain').hide();
            myScroll = new iScroll('wrapper');
            setSearch();
            setNews();
            setContent();
        });

        $(window).resize(function(){initHeader();});

        function loadUrl(url) {
            
            url = url.replace(/[=]/g, '~');
            url = url.replace(/[?]/g, '!');
            url = url.replace(/[&]/g, '*');
            url = url.replace(/[/]/g, '|');

            window.location.href = "index.htm?uuid="+uuid+"&dtype="+dtype+"&url="+url;
        }

        function clickmenu(menu) {
            var url = "";
            if (menu == "index") {
                url = "PhoneApp/Index";
            }
            else if (menu == "newarea") {
                url = "PhoneApp/NewArea";
            }
            else if (menu == "gameclassify") {
                url = "PhoneApp/GameClassify";
            }
            else if (menu == "mycode") {
                url = "PhoneApp/MyCode";
            }

            if (loadPage(url, true) != false) {
                $("li.menu").removeClass("navbar_active");
                $("li." + menu).addClass("navbar_active");
            }
        } 

        function initHeader()
        {
            routeTitle();
        }

        function routeTitle()
        {
            var $title = $(".title",".header");
            var $title_contain = $(".title_contain",".header");

            $title_contain.css("left",$title.width());

            var temp = 0-$title_contain.width();
            $title_contain.animate({"left":temp},20000,"linear",function(){
                //$title_contain.css("left",0);
                routeTitle();
            });
        }
        
    </script>
</head>
<body>
    <div id="header" class="header">
        <input type="text" class="searchtxt" placeholder="搜索..." name="name" onkeypress="enterkey()" />
        <div class="title">
            <div class="title_contain">
                
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
    <script type="text/javascript">
        function enterkey() {
            if (event.keyCode == 13) {
                event.returnValue = false;
                var url = "PhoneApp/Search?name=" + $(".searchtxt").val();
                loadPage(url, true);
            }
        }
    </script>
    <div id="wrapper">
        <div id="scroller">
            <!--<div id="error_contain">
                <div class="error">
                    网络不通，请重新尝试
                </div>
                <script type="text/javascript">
                    var height = 100; //window.screen.availHeight / 2 - $('.error').height() / 2 - $('#header').height();
                    $('.error').css("top", height);
                </script>
            </div>-->
            <div id="loading_contain">
                <div id="rotate_contain">
                    <div class="bar1">
                    </div>
                    <div class="bar2">
                    </div>
                    <div class="bar3">
                    </div>
                    <div class="bar4">
                    </div>
                    <div class="bar5">
                    </div>
                    <div class="bar6">
                    </div>
                    <div class="bar7">
                    </div>
                    <div class="bar8">
                    </div>
                </div>
                <div class="loading_text">
                    加载中 . . .
                </div>
                <script type="text/javascript">
                    var count = 0;
                    function rotate() {
                        var elem5 = document.getElementById('rotate_contain');
                        elem5.style.MozTransform = 'scale(0.5) rotate(' + count + 'deg)';
                        elem5.style.WebkitTransform = 'scale(0.5) rotate(' + count + 'deg)';
                        if (count == 360) { count = 0 }
                        count += 45;
                        window.setTimeout(rotate, 100);
                    }

                    window.setTimeout(rotate, 100);
                </script>
            </div>
        </div>
    </div>
    <div id="footer">
        <ul class="navbar">
            <li class="index menu"><a href="#" class="index" onclick="loadUrl('PhoneApp/Index')">
                <div class="navbar_item_display">
                    <img class="navbar_item_icon" src="Resource/gift.png"></img>
                    <div class="navbar_item_name">
                        游戏推荐</div>
                </div>
            </a></li>
            <li class="newarea menu"><a href="#" class="newarea" onclick="loadUrl('PhoneApp/NewArea')">
                <div class="navbar_item_display">
                    <img class="navbar_item_icon" src="Resource/newarea.png"></img>
                    <div class="navbar_item_name">
                        新区资讯</div>
                </div>
            </a></li>
            <li class="gameclassify menu"><a href="#" class="gameclassify" onclick="loadUrl('PhoneApp/GameClassify')">
                <div class="navbar_item_display">
                    <img class="navbar_item_icon" src="Resource/grid.png"></img>
                    <div class="navbar_item_name">
                        游戏分类</div>
                </div>
            </a></li>
            <li class="mycode menu"><a href="#" class="mycode" onclick="loadUrl('PhoneApp/MyCode')">
                <div class="navbar_item_display">
                    <img class="navbar_item_icon" src="Resource/user.png"></img>
                    <div class="navbar_item_name">
                        我的特权</div>
            </a></li>
            <div class="clear">
            </div>
        </ul>
    </div>
</body>
</html>
